import router from 'next/router';
import { Pagination as AntPagination, PaginationProps } from 'antd';
import { useUrlSearchParams } from 'use-url-search-params';
import RightContainer from './rightcontainer';

export default function Pagination({ onChange, ...rest }: PaginationProps) {
	const [, setParams] = useUrlSearchParams({}, { page: Number });
	return <RightContainer>
		<AntPagination
			{...rest}
			onChange={(p, s) => {
				setParams({ ...router.query, page: p });
				onChange && onChange(p, s);
			}}
		/>
	</RightContainer>;
}
